package cn.jiyun.controller;

import cn.jiyun.entity.day11.TeamDto;
import cn.jiyun.feign.UserFeign;
import cn.jiyun.utils.ResultResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title: UserController
 * @Author 王鸽
 * @Date 2023/8/22 11:16
 */
@RestController
@RequestMapping("/auser")
public class UserController {
    @Autowired
    private UserFeign userFeign;
    @RequestMapping("/findUserAll")
    public ResultResponse findUserAll(){
        ResultResponse allUser = userFeign.findAllUser();
        return ResultResponse.success(allUser);
    }

@RequestMapping("/login")
    public ResultResponse login(String username,String password){
    ResultResponse login = userFeign.login(username, password);
    if (login.getData()!=null){
        return ResultResponse.success(login);
    }else {
        return ResultResponse.error();
    }
}
    @RequestMapping("/findTeam")
    public ResultResponse findTeam(@RequestBody TeamDto teamDto){
        ResultResponse allTeam = userFeign.findAllTeam(teamDto);
        return ResultResponse.success(allTeam);
    }
    @RequestMapping("/findDept")
    public ResultResponse findDept(){
        ResultResponse dept = userFeign.findDept();
        return ResultResponse.success(dept);
    }
}
